<include file="public@header" />
</head>
<body>
	<div class="wrap" style="margin-top:20px;">
	    <ul class="nav nav-tabs">
	        <li class="active"><a href="###">个人信息</a></li>
	        <?php if ($reg && $logstate==1) { ?>
            <li><a href="{:url('cloud/goodsindex')}">商品列表</a></li>
            <li><a href="{:url('cloud/storaindex')}">仓库列表</a></li>
            <li><a href="{:url('cloud/logs')}">余额明细</a></li>
            <?php } ?>
        </ul>
		<form method="post" class="js-ajax-form" >
			<div class="row">
				<table class="table table-hover table-bordered table-striped table-condensed">
					<thead>
					<tr>
						<th>手机号</th>
						<th>账户余额</th>
						<th>{:lang('ACTIONS')}</th>
					</tr>
					</thead>
					<tbody>
					<?php if ($logstate==1) { ?>
					<tr>
						<td>{$info.username}</td>
						<td>{$info.money}</td>
						<td>
							<a class="btn btn-xs btn-success recharge" href="javascript:void(0);">余额充值</a>
							<a class="btn btn-xs btn-danger" href="{:url('cloud/sync')}">同步数据</a>
							<!--<a class="btn btn-xs btn-warning wechat" href="javascript:void(0);">客服微信</a>-->
<!--							<a class="btn btn-xs btn-primary uppwd" href="javascript:void(0);">重置密码</a>-->
<!--							<a class="btn btn-xs btn-danger" href="{//:url('cloud/logout')}">退出登录</a>-->
						</td>
					</tr>
					<?php } else { ?>
					<tr>
						<td colspan="3">
						    <?php if ($reg) { ?>
						    <a class="btn btn-default btn-primary login" href="javascript:void(0)">登录账户</a>
						    <?php } else { ?>
						    <a class="btn btn-default btn-info" href="{:url('cloud/reg')}">注册账户</a>
						    <?php } ?>
						</td>
					</tr>
					<?php } ?>
					</tbody>
				</table>
			</div>
			<input type="hidden" name="mobile" id="" value="{:isset($info.username) ? $info.username: ''}" />
		</form>
		<?php if ($service) { ?>
		<div class="warning-panel" style="width: 293px;border: 1px solid #0d84bd;border-radius: 8px;">
			<h4 class="warn-tt" style="padding: 12px 0 14px 21px;border-top-left-radius: 8px;border-top-right-radius: 8px;border-bottom: 1px solid #c2e1ea;background-color: #f3fbfe;margin-top: 0px;">服务商信息</h4>
			<div style="">
    			<ul class="warn-ct" style="list-style:none;">
    			    <li style="height: 110px; border-bottom: 0px;">
    			        <span><img border="0" src="{$service.pic}" id="imgqrcode" style="width: 100px;"></span>
    			        <span><img border="0" src="{$service.wx_qr}" id="imgqrcode" style="width: 100px;"></span>
    				</li>
    			</ul>
    			<ul class="warn-ct" style="list-style:none;">
    			    <li class="li">编号：{$service.code}</li>
    				<li class="li">姓名：{$service.name}</li>
    				<li class="li">手机：{$service.phone}</li>
    				<li class="li">微信：{$service.wx}</li>
    			</ul>
			</div>
			
		</div>
		<?php } ?>
	</div>
	<script src="__STATIC__/js/admin.js"></script>
	<script src="__STATIC__/layui/dist/layui.js"></script>
	<script type="text/javascript" charset="utf-8">
    	layui.use(['form'], function(){
    		var form = layui.form
    		, layer = layui.layer
    	});
	    $(".recharge").bind('click', function() {
	        layer.open({
	            type: 2,
    			maxmin: true,
    			area:['500px','300px'],
    			content: "{:url('cloud/recharge')}",
    			success: function(layero, index){
    				var body = layer.getChildFrame('body', index);
    				var iframeWin = window[layero.find('iframe')[0]['name']];
    			}
	        })
	    })
	    $('.login').bind('click', function() {
	        layer.prompt({title: '请输入手机号，并确认', formType: 3}, function(mob, index) {
	            layer.prompt({title: '请输入密码，并确认', formType: 1}, function(pass, index) {
	                $.post("{:url('cloud/login')}", {'mobile': mob, 'pass': pass}, function(res) {
	                    if (res.code == 1) {
	                        layer.alert(res.msg, function() {
	                            window.location.reload()
	                            layer.closeAll();
	                        })
	                    } else {
	                        layer.alert(res.msg)
	                    }
	                })
	            })
	        })
	    })
	    $(".uppwd").bind('click', function() {
	        layer.confirm('确定修改密码吗？', {
              btn: ['是的','取消'] //按钮
            }, function() {
                let mob = $("input[name='mobile']").val()
                $.post("{:url('cloud/sms')}", {'mobile': mob, 'event': 'changepwd'}, function(res) {
                    layer.alert(res.msg)
                    if (res.code == 1) {
                        layer.prompt({title: '请输入验证码，并确认', formType: 3}, function(code, index) {
	                        $.post("{:url('cloud/sms')}", {'mobile': mob, 'event': 'changepwd', 'op': 'check', 'code': code}, function(res) {
	                            if (res.code == 1) {
	                                layer.close(index)
	                                layer.prompt({title: '请输入新密码，并确认', formType: 1}, function(pass, index) {
                                        $.post("{:url('cloud/uppwd')}", {'mobile': mob, 'code': code, 'pass': pass}, function(res) {
                                            if (res.code == 1) {
                                                layer.close(index)
                                            }
                                            layer.alert(res.msg)
                                        })
                                    });
	                            } else {
	                                layer.alert(res.msg)
	                            }
	                        })
	                    })
                    }
                })
            });
	    })
	    $(".wechat").click(function() {
	        $.post("{:url('cloud/wechat')}", {}, function(res) {
	            if (res.code != 1) {
	                layer.msg(res.msg, {icon: 5})
	                return false
	            } else {
        			var imgNew = new Image();
        			imgNew.src = res.data;
        			imgNew.onload = function () {
        				var imgW = imgNew.width;
        				var imgH = imgNew.height
        				if (Number(imgW) - Number(imgH) > 0) {
        					if (Number(imgW) > 600) {
        						imgH = (600 / imgW) * imgH;
        						imgW = 600;
        					}
        				}
        				if (Number(imgH) - Number(imgW) > 0) {
        					if (Number(imgH) > 600) {
        						imgW = (600 / imgH) * imgW;
        						imgH = 600;
        					}
        				}
        				var htmlstr = '<img src="' + res.data + '" style="width: ' + imgW + 'px; height: ' + imgH + 'px;max-width: 600px; max-height: 600px;">';
        				layer.open({
        					type: 1,
        					title: false,
        					closeBtn: 1,
        					area: [imgW + 'px', imgH + 'px'],
        					skin: 'layui-layer-nobg',
        					shadeClose: true,
        					content: htmlstr
        				});
        			}
	            }
	        })
	    })
	</script>
</body>
</html>